package com.older.wptsb.controller.community;


import com.older.wptsb.domain.dto.OutingRecordDTO;
import com.older.wptsb.domain.dto.UpdateOutingRecordDTO;
import com.older.wptsb.domain.po.RequireRole;
import com.older.wptsb.domain.po.UserRole;
import com.older.wptsb.domain.vo.OutingRecordVO;
import com.older.wptsb.service.CommunityOutingService;
import com.older.wptsb.util.Result;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/outing")
public class CommunityOutingController {

    @Resource
    private CommunityOutingService communityOutingService;
    @RequireRole({UserRole.ROLE_COMMUNITY})
    @GetMapping("/get")
    public Result<List<OutingRecordVO>> getOutingRecord() {
        List<OutingRecordVO> outingRecordVO = communityOutingService.getOutingRecord();
        return Result.success(outingRecordVO);
    }
    @RequireRole({UserRole.ROLE_COMMUNITY})
    @PostMapping("/add")
    public Result<String> addOutingRecord(@RequestBody OutingRecordDTO outingRecordDTO) {
        System.out.println(outingRecordDTO);
        communityOutingService.addOutingRecord(outingRecordDTO);
        return Result.success("添加成功");
    }
    @RequireRole({UserRole.ROLE_COMMUNITY})
    @PutMapping("/update")
    public Result<String> updateOutingRecord(@RequestBody UpdateOutingRecordDTO updateOutingRecordDTO) {
        communityOutingService.updateOutingRecord(updateOutingRecordDTO);
        return Result.success("修改成功");
    }
}
